function [TR CV TE] = splitData(DATA,TRProp,CVProp,TEProp)
%function to randomly split the data set in training, cross validation and test data
%set. the parameters TRProp, CVProp, TEProp are the percentage of the data
%set in each data partion. The parameter DATA is the entire data set

%get how many examples have in the data set
len = size(DATA,1);

%calculate how many elements each partition will have
trLen = round(len * TRProp);
cvLen = round(trLen + (len * CVProp));
%teLen = round(cvLen + (len * TEProp));

% generate a vector or random integer between 0 and len
randIdx = randperm(len);

%execute the partition of the data set
TR = DATA(randIdx(1:trLen),:);  

CV = DATA(randIdx(trLen:cvLen),:); 

TE = DATA(randIdx(cvLen:end),:); 

end